package com.hmall.search.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.common.itemPojo.Item;
import com.hmall.common.searchPojo.Search;
import com.hmall.common.searchPojo.SearchVo;
import com.hmall.search.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description SearchController
 * @Author 刘
 * @Date 2024-11-15
 */
@RestController
@RequestMapping("search")
@Slf4j
public class SearchController {

    @Autowired
    private SearchService searchService;

    /**
     * 过滤项聚合功能
     * @param search
     * @return
     */
    @PostMapping("/filters")
    public SearchVo selectFilters (@RequestBody Search search){
        return searchService.selectFilters(search);
    }

    /**
     * 基本搜索功能
     * @param search
     * @return
     */
    @PostMapping("/list")
    public PageDTO<Item> selectConditional(@RequestBody Search search){
        return searchService.selectConditional(search);
    }

}